home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / oper_sys / kerberos / pc / krb_libk.lha / Lib / KRB / K_GETHST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1991-06-14  |  1.2 KB  |  50 lines

  1. /*
  2.  * $Source: /mit/kerberos/src/lib/krb/RCS/k_gethostname.c,v $
  3.  * $Author: jtkohl $
  4.  *
  5.  * Copyright 1987, 1988 by the Massachusetts Institute of Technology.
  6.  *
  7.  * For copying and distribution information, please see the file
  8.  * <mit-copyright.h>.
  9.  */
  10.  
  11. #ifndef lint
  12. static char rcsid_k_gethostname_c[] =
  13. "$Header: k_gethostname.c,v 4.1 88/12/01 14:04:42 jtkohl Exp $";
  14. #endif /* lint */
  15.  
  16. #include <mit_copy.h>
  17. #include <string.h>
  18.  
  19. #ifndef PC
  20. #ifndef BSD42
  21. teach me how to k_gethostname for your system here
  22. #endif
  23. #endif
  24.  
  25. /*
  26.  * Return the local host's name in "name", up to "namelen" characters.
  27.  * "name" will be null-terminated if "namelen" is big enough.
  28.  * The return code is 0 on success, -1 on failure.  (The calling
  29.  * interface is identical to gethostname(2).)
  30.  *
  31.  * Currently defined for BSD 4.2 and PC.  The BSD version just calls
  32.  * gethostname(); the PC code was taken from "kinit.c", and may or may
  33.  * not work.
  34.  */
  35.  
  36. void k_gethostname(name, namelen)
  37.     char *name;
  38. {
  39. #ifdef PC
  40.     char *p="localhost";
  41.     if (rhost(&p)==-1)
  42.         return -1;
  43.     strncpy(name,p,namelen);
  44. #else
  45. #ifdef BSD42
  46.     return gethostname(name, namelen);
  47. #endif
  48. #endif PC
  49. }
  50.